package com.hyt.it.ogt.kq.service.bm.service;

import cn.hutool.core.text.StrPool;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.IService;
import com.hyt.common.apiInfor.ApiResponse;
import com.hyt.it.ogt.cj.model.vo.ProjectCollectInfoVo;
import com.hyt.it.ogt.kq.service.bm.model.dto.FjzfSyncStudentDto;
import com.hyt.it.ogt.kq.service.bm.model.entity.Project;
import com.hyt.it.ogt.kq.service.bm.model.entity.StudentDetail;
import com.hyt.it.ogt.kq.service.bm.model.entity.StudentInfo;
import com.hyt.it.ogt.kq.service.bm.model.param.BatchImportManualParam;
import com.hyt.it.ogt.kq.service.bm.model.param.ProjectStudentImportRecordParam;
import com.hyt.it.ogt.kq.service.bm.model.vo.*;
import com.hyt.it.ogt.kq.service.model.param.PushCandidateParam;
import com.hyt.loginfo.model.ExamineeRegisterVO;
import com.hyt.loginfo.model.User;
import com.hyt.model.PageParam;
import lombok.SneakyThrows;
import org.apache.ibatis.annotations.Param;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletResponse;
import java.util.List;
import java.util.Map;
import java.util.Optional;

/**
 * <p>
 * 考生基础信息 服务类
 * </p>
 *
 * @author wangt
 * @since 2020-05-15
 */
public interface IStudentInfoService extends IService<StudentInfo> {

    String XLSX_FILE_TYPE = "xlsx";
    String XLSX_FILE_SUFFIX = StrPool.DOT + "xlsx";
    String IMPORT_YES = "是";
    String IMPORT_NO = "否";
    String[] SUBJECT_TEMPLATE_OPTIONS = {IMPORT_YES, IMPORT_NO};

    String SUBJECT_NAME = "科目";

    String saveList(Project project, List<StudentInfo> list, StudentInfoListVo studentInfoListVo);

    String batchImportManual(String projectId, List<StudentInfo> list, Boolean createFlag, List<String> subjectIds);

    List<StudentInfoVo> getByStudentId(@Param("projectId") String projectId, @Param("studentId") String studentId);

    Integer saveOrUpdateStu(Project project, StudentInfoListVo studentInfoListVo, String active);

    StudentProjectInfoVo getProjectSubjectById(String projectId, String regId);

    List<StudentVo> queryStudentList(StudentParam studentParam, List<String> permissionList, long current, long size);

    long queryStudentListCount(StudentParam studentParam, List<String> permissionList);

    StudentDetail getStudentInfo(String projectId, String studentId);

    void export(HttpServletResponse response, List<String> permissionList, StudentParam studentParam);

    void zip(HttpServletResponse response, List<String> permissionList, StudentParam studentParam);

    void exportStudentList(HttpServletResponse response, StudentInfoParam param) throws Exception;

    String downLoadStudentList(StudentInfoParam param);

    List<StudentProjectVo> queryStudentProject(String regId);

    String uploadFile(MultipartFile file, String projectCollectInfoId);

    IPage<StudentInfoDeatailVo> getPageStudent(PageParam<StudentInfoDeatailVo> pageParam, String enrollId, String subjectId, String queryStr, String auditState, String payState);

    List<StudentSubjectDetailVo> getProjectSubjectByStuId(String projectId, String studentId);

    void isAgainData(StudentInfoListVo studentInfoListVo);

    void checkData(StudentInfoListVo studentInfoListVo);

    void batchImportManualDataCheck(BatchImportManualParam studentInfoListVo);

    List<StudentInfo> getByProjectId(String projectId);

    void importMulFile(MultipartFile file, String officeId, String projectId, Boolean createUser, User user);

    ExamineeRegisterVO createExamineeRegisterVO(String officeId, ProjectStudentImportRecordParam recordParam, Map<String, String> map);

    ApiResponse createUser(String officeId, ImportStudentVo vo);

    String uploadEnclosureFile(MultipartFile file, String projectCollectInfoId);

    /**
     * 查询区域ID下的报名项目考生数量
     *
     * @param projectId
     * @param collectInfoId
     * @return
     */
    List<UserPermissionStatVo> getAreaProjectStudentNum(String projectId, String collectInfoId);

    /**
     * 非区域的报名考生数
     *
     * @param projectId
     * @return
     */
    Optional<UserPermissionStatVo> getNonAreaProjectStudentNum(String projectId, String deptId);

    /**
     * 装配考生信息，在这里需要封装一层添加考生信息数据
     *
     * @param param
     * @return
     */
    void assembleCandidateInfo(PushCandidateParam param);

    /**
     * 获取所有的考生信息
     *
     * @param projectId  报名ID
     * @param isPay      是否支付
     * @param isAudit    是否审核
     * @param infoPageNo 当前页号
     * @param pageSize   页大小
     * @return
     */
    List<StudentInfo> queryAllStudentInfo(String projectId, String isPay, String isAudit, int infoPageNo, int pageSize);

    /**
     * 查看考生基础信息数据
     *
     * @param projectId
     * @param studentId
     * @return
     */
    ApiResponse<Object> newQuery(String projectId, String studentId);

    /**
     * 查看考生基础信息数据
     *
     * @param studentId
     * @param projectId
     * @return
     */
    ApiResponse<Object> queryStudentBaseInfo(String studentId, String projectId);

    ApiResponse<Object> updateStudentInfoData(StudentInfoListVo studentInfoListVo);

    ApiResponse<Object> addStudentInfoData(StudentInfoListVo studentInfoListVo);

    /**
     * 通过考生ID查询考生的信息
     *
     * @param projectId
     * @param studentId
     * @return
     */
    List<StudentInfo> listByStudentId(String projectId, String studentId);

    Boolean validateSingUpEnd(Project project);

    /**
     * 集体报名文件录入
     *
     * @param projectId
     * @param fileUrl
     * @param createFlag
     * @param user
     */
    void batchImportFile(String projectId, String fileUrl, Boolean createFlag, User user);

    /**
     * 集体报名模板下载
     *
     * @param projectId
     * @return
     */
    String batchImportTemplate(String projectId);

    /**
     * 福建执法同步考生信息
     *
     * @param fjzfSyncStudentDto
     * @return
     */
    FjzfSyncStudentDto syncFjzfStudentInfo(FjzfSyncStudentDto fjzfSyncStudentDto);

    /**
     * 构造报名采集项树形结构真实value
     *
     * @param studentValue
     * @param projectCollectInfoId
     * @param projectId
     * @return
     */
    String buildOptionTreeRealValueByValue(String studentValue, String projectCollectInfoId, String projectId);

    /**
     * 构造报名采集项树形结构真实value
     *
     * @param studentValue
     * @param projectCollectInfoId
     * @param projectId
     * @return
     */
    String buildOptionTreeRealValueByLabel(String studentValue, String projectCollectInfoId, String projectId);

    /**
     * 构造报名采集项树形结构真实value
     *
     * @param studentValue
     * @param projectCollectInfoId
     * @param projectCollectInfoVos
     * @return
     */
    String buildOptionTreeRealValueByLabel(String studentValue, String projectCollectInfoId, List<ProjectCollectInfoVo> projectCollectInfoVos);

    /**
     * 通过考生ID和采集项ID获取采集值
     *
     * @param projectId
     * @param collectInfoId
     * @return
     */
    String getValueByStudentIdAndCollectInfoId(String projectId, String studentId, String collectInfoId);

    /**
     * 获取考生信息的指定采集参数
     *
     * @param projectId
     * @param studentId
     * @param projectCollectInfoId
     * @return
     */
    StudentInfo getStudentInfoByCollectInfoId(String projectId, String studentId, String projectCollectInfoId);
}
